<?php

class Wlib_Controller_Action_Helper_LoadViewTranslator extends Zend_Controller_Action_Helper_Abstract
{
    public function loadViewTranslator()
    {
        $loader = new Wlib_Translate_Loader();
        $translator = $loader->loadTranslator($this->getActionController());

        if($translator) {
            $view = $this->getActionController()->view;
            $view->translate()->getTranslator()->addTranslation($translator);
        }

        return $translator;
    }

    public function preDispatch()
    {
        $this->loadViewTranslator();
    }
}
